package com.guxingke.typecho4j;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.guxingke.typecho4j.jfinal.model.Option;

/**
 * typecho4j的运行时配置属性类
 * 
 * @author guxingke
 *
 */
public final class Constants {
	private List<String> widgetPackageNames = new ArrayList<String>();

	private int pageSize = 5;
	private int postsListSize = 10;
	private String postDataFormat = "MM/dd/YY/ HH:mm:ss";
	private String siteUrl;

	// 主题设置
	private String usrThemeTemplatePath = Const.DEFAULT_USR_THEME_TEMPLATE_PATH;
	private String activeThemeName = Const.DEFAULT_THEME_NAME;
	private String activeThemePath = this.getUsrThemeTemplatePath()
			+ File.separator + activeThemeName;

	private String uploadPath = Const.FILE_UPLOAD_PATH;

	private boolean isShowRecentPosts;
	private boolean isShowRecentComments;
	private boolean isShowCategory;
	private boolean isShowArchive;
	private boolean isShowOther;

	{
		InitThemeConfig();
	}

	private void InitThemeConfig() {
		isShowRecentPosts = ("1".equals(Option.dao
				.getValue("ShowRecentPosts"))) ? true : false;
		isShowRecentComments = ("1".equals(Option.dao
				.getValue("showRecentComments"))) ? true
				: false;
		isShowCategory = ("1".equals(Option.dao
				.getValue("showCategory"))) ? true : false;
		isShowArchive = ("1".equals(Option.dao.getValue("showArchive"))) ? true
				: false;
		isShowOther = ("1".equals(Option.dao.getValue("showOther"))) ? true
				: false;
	}

	public void refreshThemeConfig() {
		this.InitThemeConfig();
	}

	public boolean isShowRecentPosts() {
		return isShowRecentPosts;
	}

	public boolean isShowRecentComments() {
		return isShowRecentComments;
	}

	public boolean isShowCategory() {
		return isShowCategory;
	}

	public boolean isShowArchive() {
		return isShowArchive;
	}

	public boolean isShowOther() {
		return isShowOther;
	}

	public String getUploadPath() {
		return uploadPath;
	}

	public String getPostDataFormat() {
		return postDataFormat;
	}

	public void setPostDataFormat(String postDataFormat) {
		this.postDataFormat = postDataFormat;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public String getSiteUrl() {
		return siteUrl;
	}

	public void setSiteUrl(String siteUrl) {
		this.siteUrl = siteUrl;
	}

	public int getPostsListSize() {
		return postsListSize;
	}

	public void setPostsListSize(int postsListSize) {
		this.postsListSize = postsListSize;
	}

	public String getUsrThemeTemplatePath() {
		return usrThemeTemplatePath;
	}

	public void setUsrThemeTemplatePath(String usrThemeTemplatePath) {
		this.usrThemeTemplatePath = usrThemeTemplatePath;
	}

	public String getActiveThemePath() {
		return activeThemePath;
	}

	public void setActiveThemePath(String activeThemePath) {
		this.activeThemePath = activeThemePath;
	}

	public void add(String value) {
		this.widgetPackageNames.add(value);
	}

	public List<String> getWidgetPackageNames() {
		return this.widgetPackageNames;
	}

	public String getActiveThemeName() {
		return activeThemeName;
	}

	public void setActiveThemeName(String activeThemeName) {
		this.activeThemeName = activeThemeName;
	}
}
